<extend name="Common/common" />
<block name="main">
  <div id="page-wrapper" class="gray-bg dashbard-1">
    <include file="Common/nav-header"/> <!--顶部-->
    <div class="wrapper wrapper-content">
      <div class="col-lg-12">
        <div class="ibox float-e-margins">
          <div class="ibox-title">
            <h5>{$get_id?'编辑文章':'添加文章'}</h5>
          </div>
          <div class="ibox-content">
            <form class="form-horizontal m-t " method="post" action="{:U('add')}">
              <if condition="$get_id neq null">
                <volist name="data" id="vo1">
                  <h3>请输入标题</h3>
                  <div class="input-group input-group-lg">
                    <input type="hidden" name="id" value="{$vo1.id}">
                    <span class="input-group-addon" id="sizing-addon1">@</span>
                    <input type="text" name="title" class="form-control" placeholder="请输入文章标题..." aria-describedby="sizing-addon1" value="{$vo1.title}">
                  </div>  
                  <h3>请选择分类</h3>
                  <select name="category">
                    <volist name="list" id="vo2">
                      <eq name="vo2.category" value="$vo1.category">
                        <option value="{$vo2.category}" selected="selected">{$vo2.category}</option>
                        <else />
                        <option value="{$vo2.category}">{$vo2.category}</option>
                      </eq>
                    </volist>
                  </select>
                  <h3>请选择标签</h3>
                  <volist name="tag" id="vo3">
                    <in name="vo3.id" value="{$tids}">
                      <label class="checkbox-inline">
                        <input type="checkbox" id="inlineCheckbox1" name="tid[]" value="{$vo3.id}" checked="checked">
                        {$vo3.name}
                      </label>
                      <else />
                      <label class="checkbox-inline">
                        <input type="checkbox" id="inlineCheckbox1" name="tid[]" value="{$vo3.id}">
                        {$vo3.name}
                      </label>
                    </in>


                  </volist>
                  <h3>请输入文章内容</h3>
                  <!-- 加载编辑器的容器 -->
                  <script id="container" name="content" type="text/plain">
                    {$vo1.content|html_entity_decode}
                  </script>
                  <!-- 配置文件 -->
                  <script type="text/javascript" src="__PUBLIC__/static/ueditor/ueditor.config.js"></script>
                  <!-- 编辑器源码文件 -->
                  <script type="text/javascript" src="__PUBLIC__/static/ueditor/ueditor.all.js"></script>
                  <!-- 实例化编辑器 -->
                  <script type="text/javascript">
                    var ue = UE.getEditor('container');
                  </script>
                  <h3>是否显示</h3>
                  <select name="status">
                    <option value="1">是</option>
                    <option value="0">否</option>
                  </select>
                  <h3>是否推荐</h3>
                  <select name="recommend">
                    <option value="0">否</option>
                    <option value="1">是</option>
                  </select>
                  <div class="form-group">
                    <div class="col-sm-4" style="margin-top: 10px;">
                      <button class="btn btn-primary" type="submit">提交</button>
                    </div>
                  </div>
                </volist>
                <else />
                <h3>请输入标题</h3>
                <div class="input-group input-group-lg">
                  <span class="input-group-addon" id="sizing-addon1">@</span>
                  <input type="text" name="title" id="title" class="form-control" placeholder="请输入文章标题..." aria-describedby="sizing-addon1">
                </div>  
                <h3>请选择分类</h3>
                <select name="category">
                  <volist name="list" id="vo2">
                    <option value="{$vo2.category}">{$vo2.category}</option>
                  </volist>
                </select>
                <h3>请选择标签</h3>
                <volist name="tag" id="vo3">
                  <label class="checkbox-inline">
                    <input type="checkbox" id="inlineCheckbox1" name="tid[]" value="{$vo3.id}">
                    {$vo3.name}
                  </label>
                </volist>
                <h3>请输入文章内容</h3>
                <!-- 加载编辑器的容器 -->
                <script id="container" name="content" type="text/plain">

                </script>
                <!-- 配置文件 -->
                <script type="text/javascript" src="__PUBLIC__/static/ueditor/ueditor.config.js"></script>
                <!-- 编辑器源码文件 -->
                <script type="text/javascript" src="__PUBLIC__/static/ueditor/ueditor.all.js"></script>
                <!-- 实例化编辑器 -->
                <script type="text/javascript">
                  var ue = UE.getEditor('container');
                </script>
                <h3>是否显示</h3>
                <select name="status">
                  <option value="1">是</option>
                  <option value="0">否</option>
                </select>
                <h3>是否推荐</h3>
                <select name="recommend">
                  <option value="0">否</option>
                  <option value="1">是</option>
                </select>
                <div class="form-group">
                  <div class="col-sm-4" style="margin-top: 10px;">
                    <button class="btn btn-primary" type="submit">提交</button>
                  </div>
                </div>
              </if>
            </form>
          </div>
        </div>
      </div>
    </div>
    <!--尾部-->
    <include file="Common/admin:footer"/>
  </div>

  <script>
    $('form').submit(function(){
      var title = $('#title').val();
      var editor = $("#editor").val();
      if(title == ''){
        layer.msg('请填写文章标题',{time:1000});
        return false;
      }
      if(editor == ''){
        layer.msg('请填写文章内容',{time:1000});
        return false;
      }
    });
  </script>
</block>

